*--------------------------------------------------------------------*
* Project: Pregnancy Testing: Prevalence and Barriers in Uganda 
* Last updated: Akito on 2022/07/15
*--------------------------------------------------------------------*
clear all               
set graph on
version 17

* Set your path
global Path   "" [Set your own path]

* Input: Opens clean dataset
cap program drop start_from_clean_file
program define   start_from_clean_file
  use "${Path}BL_analysis_sample_Descriptive_Shared.dta", clear
  gen ID=_n
 
end

* Outputs: 
* Figure 1: Awareness and past use of home pregnancy testing kits
* Table 1: Characteristics of women who are uncertain about her pregnancy status (N=1,032)
* Table 2: Barrier to access pregnancy testing kits among women who knows home pregnancy testing kits (N=676)
* Table 3: Husband's attitude toward home pregnancy testing kit and private information of purchase (odds-ratio)
* Table S.1: Utilization of pregnancy testing kits among ever used (N=306)
*--------------------------------------------------------------------

*********************
* Set variable list *
*********************
global ListPT1  Relation_1 Relation_2 Age_5_1 Age_5_2 Age_5_3 Age_5_4 ///
                Edu_year_categ2_0 Edu_year_categ2_1 Edu_year_categ2_2 ///
                WORK povassets_1 povassets_2 povassets_3 povassets_4 ///
                Num_preg_categ_0 Num_preg_categ_1 Num_preg_categ_2 Num_preg_categ_3 ///
				Desire_children_1 Desire_children_2 Desire_children_3 Desire_children_4 ///
				Husb_desire_1 Husb_desire_2 Husb_desire_3 Husb_desire_98 Dist_HC_1 Dist_HC_2 Dist_HC_3 Dist_HC_4 Dist_HC_5
global ListPT2  i2_a_a i2_a_b i2_a_c Husb_Supportive_1 Husb_Supportive_2 Husb_Supportive_3 Husb_Supportive_98
global ListPT3  i4_1 i4_2 i4_3 i4_4 i4_5 i5 i7_a i7_b i7_c i7_d i7_e i7_f i7_g i7_h i7_i i8 i8_a_a i8_a_b i8_a_c

*******************************************************************
* Figure 1: Awareness and past use of home pregnancy testing kits *
*******************************************************************
start_from_clean_file
recode PT_Categ 1=1 2 3=2 4=3
tab PT_Categ, matcell(M)
graph pie, over(PT_Categ) plabel(_all percent, size(vlarge) format(%9.0f) color(white)) ///
       legend(order(1 "(1) I do not know pregnancy test kits" "N=`=M[1,1]'" 2 "(2) I know but never used one" "N=`=M[2,1]'" 3 "(3) I have used one" "N=`=M[3,1]'" ) )

********************************************************************************************
* Table 1: Characteristics of women who are uncertain about her pregnancy status (N=1,032) *
********************************************************************************************
start_from_clean_file

local ListPT1      "Characteristics of women who are uncertain about her pregnancy status (N=1,032)"
local noteListPT1  "Note: $^{\dagger}$ Desired for children is with respect to women."

eststo summstats0: estpost summarize $ListPT1
eststo summstats1: estpost summarize $ListPT1 if PT_Categ==1
eststo summstats2: estpost summarize $ListPT1 if PT_Categ==2 | PT_Categ==3
eststo summstats3: estpost summarize $ListPT1 if PT_Categ==4

	foreach i in $ListPT1 {
	egen Mean_D0_`i'_temp=mean(`i') if PT_Categ==1
	egen Mean_D0_`i'= mean(Mean_D0_`i'_temp)
	egen Mean_D1_`i'_temp=mean(`i') if PT_Categ==2 | PT_Categ==3 | PT_Categ==4
	egen Mean_D1_`i'= mean(Mean_D1_`i'_temp)
	replace `i'=Mean_D1_`i'-Mean_D0_`i'
	}
	eststo summstats4: estpost summarize $ListPT1

start_from_clean_file
	foreach i in $ListPT1 {
	egen Mean_D0_`i'_temp=mean(`i') if PT_Categ==2 | PT_Categ==3
	egen Mean_D0_`i'= mean(Mean_D0_`i'_temp)
	egen Mean_D1_`i'_temp=mean(`i') if PT_Categ==4
	egen Mean_D1_`i'= mean(Mean_D1_`i'_temp)
	replace `i'=Mean_D1_`i'-Mean_D0_`i'
	}
	eststo summstats5: estpost summarize $ListPT1
esttab summstats1 summstats2 summstats3 summstats4 summstats5 using "${Path}D_Main_ListPT1.tex", replace ///
       cell("mean (fmt(2) label(\%))") label ///	   
	   mtitle("\shortstack{Do not know\\pregnancy\\testing kits}" "\shortstack{I know\\pregnancy testing\\kits but\\never used}" "\shortstack{I have used\\pregnancy\\testing kits}" ///
	          "\shortstack{Diff\\(2 \& 3)-(1)}" "\shortstack{Diff\\(3)-(2)}") ///
	   substitute("{l}{\footnotesize" "{p{1\linewidth}}{\footnotesize"  ///
	   "Husb Supportive: Yes, he will be supportive" "Husband Attitude towards purchase of pregnancy test kit \\ ~~~He will be supportive" "Husb Supportive: " "~~~" ///
       "PT: Able to buy by myself" "If you want to buy pregnancy testing kit\\ ~~~I am able to buy by myself" "PT: " "~~~" ///
	   "Married with husband" "Relationship\\~~~Married with husband" "Have a partner" "~~~Have a partner" ///
	   "Age: 18-20" "Age of respondents\\~~~18-20" "Age: " "~~~"  ///
	   "Num preg: 0" "Number of pregnancy\\~~~0 (Never been pregnant)" "Num preg: " "~~~" ///
	   "DistanceHC3: 0-1 km" "Distance to Health Center 3\\~~~0-1 km" "DistanceHC3: " "~~~" ///
	   "Husb desire: Same number" "Husband desire for children$^{\dagger}$ \\~~~Same number" "Husb desire: " "~~~" ///
	   "Desire children: Have a/another child" "Desire for children\\~~~Have a/another child" "Desire children: " "~~~" ///
	   "Eligibility: Unable to get pregnant" "~~~Unable to get pregnant" ///
	   "Num PreT: 1" "Number of pregnancy testing kit used in her life\\~~~1 "  "Num PreT: " "~~~" ///
	   "Educ: Incomplete primary school" "Education\\~~~Incomplete primary school"  "Educ: " "~~~" ///
	   "Wealth: 1" "Wealth quartile\\~~~1" "Wealth: " "~~~"  ///
	   "Job: Firm, sell, and wage" "Job\\~~~Firm, sell, and wage"  ///
	   "Obtained PT at Pharmacy (Drug shop)" "\textbf{Among who purchased pregnancy test by own (N=51)}\\\hline Where she obtained \\~~~Pharmacy (Drug shop)"  "Obtained PT at " "~~~" ///
	   "Reason, No stock available" "\textbf{Among who fail to get pregnancy test (N=10)}\\\hline Reason for failing to obtain \\~~~No stock available"  "Reason, " "~~~" ///
	   "Told: Husband/Partner" "\textbf{Among who told others (N=38)}\\\hline To whom she told \\~~~Husband/Partner"  "Told: " "~~~" ///
	   "Undecided/DK" "Undecided/Don't know" /// 
	    "0.0" " " "0." " " "- 0" "0" "- " "-" "1032" "1,032"   ///
		"Have a partner (never lived together)" "Partner who never lived" ///
		"Hiher" "Higher" "Don't know" "Do not know") ///	   
	   title("`ListPT1'" \label{LabelListPT1}) addnote("`noteListPT1'")
eststo clear

***************************************************************************************************************
* Table 2: Barrier to access pregnancy testing kits among women who knows home pregnancy testing kits (N=676) *
***************************************************************************************************************
start_from_clean_file

local  ListPT2       "Barrier to access pregnancy testing kits among women who knows home pregnancy testing kits (N=676)"
local  noteListPT2   "Note: Questions about finnancial freedom for the purchase are multiple choices."

eststo summstats0: estpost summarize $ListPT2
eststo summstats1: estpost summarize $ListPT2 if PT_Categ==2 | PT_Categ==3
eststo summstats2: estpost summarize $ListPT2 if PT_Categ==4
esttab summstats0 summstats1 summstats2 using "${Path}D_Main_ListPT2.tex", replace ///
       cell("mean (fmt(2) label(\%))") label nonum ///
	   mtitle("\shortstack{Full sample\\Women who\\knows pregnancy\\testing kits}" "\shortstack{I know\\pregnancy\\testing kits but\\never used}" "\shortstack{I have used\\pregnancy\\testing kits}") ///
	   substitute("{l}{\footnotesize" "{p{1\linewidth}}{\scriptsize" "                    &\multicolumn{2}{c}{}     \\" " "  ///
	   "Husb Supportive: Yes, he will be supportive" "\textbf{Husband's attitude towards the purchase} \\ ~~~He will be supportive" "Husb Supportive: " "~~~" ///
       "PT: Able to buy by myself" "\textbf{Finnancial freedom for the purchase}\\ ~~~I am able to buy by myself" "PT: " "~~~" ///
	   "Married with husband" "Relationship\\~~~Married with husband" "Have a partner" "~~~Have a partner" ///
	   "Age: 18-20" "Age of respondents\\~~~18-20" "Age: " "~~~"  ///
	   "Num preg: 0" "Number of pregnancy\\~~~0 (Never been pregnant)" "Num preg: " "~~~" ///
	   "DistanceHC3: 0-1 km" "Distance to Health Center 3\\~~~0-1 km" "DistanceHC3: " "~~~" ///
	   "Husb desire: Same number" "Husband desire for children (with respect to women)\\~~~Same number" "Husb desire: " "~~~" ///
	   "Desire children: Have a/another child" "Desire for children\\~~~Have a/another child" "Desire children: " "~~~" ///
	   "Num PreT: 1" "Number of pregnancy testing kit used in her life\\~~~1 "  "Num PreT: " "~~~" ///
	   "Obtained PT at Pharmacy (Drug shop)" "\textbf{Among who purchased pregnancy test by own (N=51)}\\\hline Where she obtained \\~~~Pharmacy (Drug shop)"  "Obtained PT at " "~~~" ///
	   "Reason, No stock available" "\textbf{Among who fail to get pregnancy test (N=10)}\\\hline Reason for failing to obtain \\~~~No stock available"  "Reason, " "~~~" ///
	   "Told: Husband/Partner" "\textbf{Among who told others (N=38)}\\\hline To whom she told \\~~~Husband/Partner"  "Told: " "~~~" ///
	   "~~~Hide from your husband/partner" "\textbf{Confidentiality of the purchase} \\ ~~~Hide from your husband/partner" ///
	   "No, he will not be supportive" "He will not be supportive" "Don't know" "Do not know" ///
	   "0.0" " " "0." " ") ///	   
	   title("`ListPT2'") addnote("`noteListPT2'")
eststo clear

******************************************************************************************************************
* Table 3: Husband's attitude toward home pregnancy testing kit and private information of purchase (odds-ratio) *
******************************************************************************************************************
start_from_clean_file

eststo: logit Husb_Supportive_3 i.Relation i.Age_5 i.Edu_year_categ2 i.h8_choice_0 i.povassets i.Desire_children i.Husb_desire i2_a_a i.never_preg 
sum Husb_Supportive_3
estadd scalar Mean = r(mean)

eststo: logit i2_a_c i.Relation i.Age_5 i.Edu_year_categ2 i.h8_choice_0 i.povassets i.Desire_children i.Husb_desire i2_a_a i.never_preg 
sum Husb_Supportive_3
estadd scalar Mean = r(mean)

esttab using "${Path}Non_Supportive.tex", label se ar2 title("Husband's attitude toward home pregnancy testing kit and private information of purchase (odds-ratio)") ///
			 nobase nonotes eform cells(b(star fmt(3)) ci(par fmt(2))) stats(N, fmt(0) labels( `"Observations"'))  ///
			 star(* .10 ** .05 *** .01) b(3) drop(_cons)  ///
			 mtitle("\shortstack{\textbf{Outcome 1}\\Husband not\\being supportive\\for purchase of\\pregnancy testing kit}" "\shortstack{\textbf{Outcome 2}\\Hide from your\\husband/partner \\ if I purchase\\pregnancy testing kit}") ///
			 substitute("{l}{\footnotesize" "{p{0.93\linewidth}}{\footnotesize" ///
			            "=1" "" ///
						"main                &                     &                     \\" "\textbf{Marital status (Base: Married)} & & \\" ///
						"Have a partner (never lived together)" "Have a partner (but never lived together)" ///
						"Age: 21-25" "\textbf{Age (Base: Age 18-20)} \\ ~~~ 21-25" "Age:" " ~~~" /// 
						"Resp Job: No Occupation" "\textbf{Job} \\ ~~~ No occupation" ///
						"Wealth: 2" "\textbf{Wealth quartile (Base: Poorest)} \\ ~~~ 2" "Wealth: " "~~~ " ///
						"Educ: Primary school completed" "\textbf{Education  (Base: Incomplete primary school)} \\ ~~~ Primary school completed"  "Educ: " "~~~" ///
						"Never been pregnant" "\textbf{Past Pregnancy} \\ ~~~ Never been pregnant" ///
						"Desire children: None/no more" "\textbf{Desire for children (Base: Want more children)} \\ ~~~ None or no more children" "Desire children:" "~~~ " ///
						"Husb Supportive: No, he will not be supportive" "" ///
						"PT: Able to buy by myself" "\textbf{Financial}\\ ~~~ Able to buy by myself" ///
						"Husb desire: More children" "\textbf{Husband's Desire for children (Base: Same number)} \\ ~~~ More children" "Husb desire:" "~~~ " ///
						"Hiher" "Higher" "Undecided/DK" "Undecided/Don't know" "Can't get pregnant" "Cannot get pregnant" "Don't know" "Do not know" "Refused to Answer" "Refused to answer" ///
						) ///
			 addnote("Note: Observations are at the women's level. Outcome 1 takes one if the husband is reported to be not supportive of purchasing home pregnancy testing kits, and Outcome 2 takes one if a woman reported hiding from her husband/partner if she purchased home pregnancy testing kits. 95 percent confidence interval in parentheses, $\sym{*} p<.10,\sym{**} p<.05,\sym{***} p<.01$.") ///
			 replace
eststo clear

****************************************************************************
* Table S.1: Utilization of pregnancy testing kits among ever used (N=306) *
****************************************************************************
start_from_clean_file
local  ListPT3   "Utilization of pregnancy testing kits among ever used (N=306)"

eststo summstats0: estpost summarize $ListPT3
esttab summstats0 using "${Path}D_Main_ListPT3.tex", replace ///
       cell("sum (fmt(0) label(Frequency (N))) mean (fmt(2) label(Percentage (\%)))") label nonum ///
	   substitute("{l}{\footnotesize" "{p{1\linewidth}}{\scriptsize" "                    &\multicolumn{2}{c}{}     \\" " "  ///
	   "Husb Supportive: Yes, he will be supportive" "\textbf{Husband attitude towards the purchase} \\ ~~~He will be supportive" "Husb Supportive: " "~~~" ///
       "PT: Able to buy by myself" "\textbf{Finnancial freedom for the purchase}\\ ~~~I am able to buy by myself" "PT: " "~~~" ///
	   "Married with husband" "Relationship\\~~~Married with husband" "Have a partner" "~~~Have a partner" ///
	   "Age: 18-20" "Age of respondents\\~~~18-20" "Age: " "~~~"  ///
	   "Num preg: 0" "Number of pregnancy\\~~~0 (Never been pregnant)" "Num preg: " "~~~" ///
	   "DistanceHC3: 0-1 km" "Distance to Health Center Three\\~~~0-1 km" "DistanceHC3: " "~~~" ///
	   "Husb desire: Same number" "Husband desire for children (with respect to women)\\~~~Same number" "Husb desire: " "~~~" ///
	   "Desire children: Have a/another child" "Desire for children\\~~~Have a/another child" "Desire children: " "~~~" ///
	   "Num PreT: 1" "Number of pregnancy testing kits used in her life\\~~~1 "  "Num PreT: " "~~~" ///
	   "Obtained PT at Pharmacy (Drug shop)" "\\ \textbf{\shortstack[l]{Among who purchased pregnancy testing kits\\by own (N=51)}}\\\hline Where she obtained \\~~~Pharmacy (Drug shop)"  "Obtained PT at " "~~~" ///
	   "Reason, No stock available" "\textbf{Among who fail to get pregnancy test (N=10)}\\\hline Reason for failing to obtain \\~~~No stock available"  "Reason, " "~~~" ///
	   "Told: Husband/Partner" "\\ \textbf{Among who told the purchase to others (N=38)}\\\hline To whom she told \\~~~Husband/Partner"  "Told: " "~~~" ///
	   "~~~Hide from your husband/partner" "\textbf{Confidentiality of the purchase} \\ ~~~Hide from your husband/partner" ///
	   "0." "" ///
	   "Purchased pregnancy test yourself?" "Purchased pregnancy testing kits by yourself?" ///
	   "other public HC" "Other public HC" "private health facility" "Private health facility" "hospital" "Hospital" ///
	   "partner/husband" "Partner/husband" "friend/family" "Friend/family" "other family" "Other family" ///
	   "Told anyone when you bought the PT?" "Told anyone when you bought the pregnancy testing kits?" ///
	   ) ///	   
	   title("`ListPT3'") addnote("`noteListPT3'")
eststo clear
